<template>
  <!--销售报价-->
  <el-dialog
    :close-on-click-modal="false"
    title="销售报价"
    :visible.sync="dialogVisible3"
    width="400px"
  >
    <div>
      <el-form
        size="mini"
        :model="sendForm3"
        label-width="100px"
        ref="sendForm3"
        :rules="rules3"
      >
        <el-form-item label="销售报价：" prop="moresuPrice">
          <el-input
            type="number"
            @change="checkInput"
            v-model="sendForm3.moresuPrice"
            style="width: 150px"
          ></el-input>
        </el-form-item>
      </el-form>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="handleClose3">取 消</el-button>
      <el-button type="primary" @click="handleConfirm3" :loading="btnLoading3"
        >确认</el-button
      >
    </span>
  </el-dialog>
</template>
<script>
import { inquiryOperate } from "@/api/allInLine/inquiry";
import { mapGetters } from "vuex";
import { Message } from "element-ui";

const defaultSendForm3 = {
  inquiryId:'',
  moresuPrice: "",
  priceId: "",
  operateType:'pushMoresuPrice'
};

export default {
  name: "index",

  data() {
    return {
      dialogVisible3: false,
      btnLoading3: false,
      sendForm3: JSON.parse(JSON.stringify(defaultSendForm3)),
      rules3: {
        moresuPrice: [
          { required: true, message: "请填写报价金额", trigger: "blur" },
        ],
      },

    };
  },
  computed: {
    ...mapGetters(["name", "mobile", "userId"]),
  },
  components: {},
  created() {},
  filters: {},
  methods: {
    checkInput() {
      if (this.sendForm3.moresuPrice < 0) {
        this.sendForm3.moresuPrice = "0";
      }
      if (this.sendForm3.moresuPrice > 999999) {
        this.sendForm3.moresuPrice = "999999";
      }
    },

    //显示
    showPop3(item) {
      this.dialogVisible3 = true;
      this.sendForm3 = JSON.parse(JSON.stringify(defaultSendForm3));
      this.sendForm3.priceId = item.priceId;
      this.sendForm3.inquiryId = item.inquiryId;
      this.$refs.sendForm3.resetFields();
    },
    //关闭
    handleClose3() {
      this.dialogVisible3 = false;
      this.sendForm3 = JSON.parse(JSON.stringify(defaultSendForm3));
    },

    //确认
    handleConfirm3() {
      this.$refs.sendForm3.validate((valid) => {
        if (valid) {
          this.btnLoading3 = true;
          inquiryOperate(this.sendForm3)
            .then((res) => {
              this.$message.success("提交成功");
              this.dialogVisible3 = false;
              this.$emit("update");
              this.btnLoading3 = false;
            })
            .catch((err) => {
              this.btnLoading3 = false;
            });
        }
      });
    },
  },
};
</script>

<style  lang="scss">
</style>
